package com.zkk.tankgame04;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

public class ZkkTankGame02 extends JFrame {
    static Scanner scanner = new Scanner(System.in);
    //定义MyPanel
    MyPanel mp = null;
    public static void main(String[] args) {
        ZkkTankGame02 zkkTankGame01 = new ZkkTankGame02();
    }
    public ZkkTankGame02(){
        System.out.println("请输入您的选择（1：新游戏 2：继续上一局）");
        String Key = scanner.next();

        mp = new MyPanel(Key);//创建画板
        //将mp放入到Thread，并启动
        Thread thread = new Thread(mp);
        thread.start();
        this.add(mp);//添加面板（即绘图区域）这个控件
        this.setSize(1300,950);
        this.addKeyListener(mp);//让JFrame监听mp的键盘事件
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
        //让JFrame中增加相应关闭窗口的处理
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                Recorder.keepRecord();
                System.exit(0);
            }
        });
    }



}
